<extend name="Public@Public/base" />


<block name="main_content">
<table class="table table-bordered datalist table-hover tree_list">
  <thead>
    <tr>
      <foreach name="title_lists" item="row">
        <th>
          {$row}
        </th>
      </foreach>
      <th>
        操作
        <if condition="$action_add_button neq false">
        <a href="{:U($action_add_button['node_name'])}" class="btn btn-primary btn-sm"><i class="{$action_add_button['img']}"></i>
          {$action_add_button['title']}
        </a>
        </if>
      </th>
    </tr>
  </thead>
  <tbody>
    <?php
    function my_set_tree($tree,$title_lists,$action_lists,$model,$root=true)
    {
      foreach ($tree as $row) {
        if ($root) {
          echo "<tr style='background:#f8f8f8'>";
        }
        else{
          echo "<tr>";
        }
            foreach ($title_lists as $key2 => $row2) {
              if ($key2=="cat_name") {
                echo "<td>".set_tree_style($row['lev']).get_model_value($row[$key2],$model,$key2)."</td>";
              }
              else{
                echo "<td>".get_model_value($row[$key2],$model,$key2)."</td>";
              }
            }

            echo  "<td width='280'>";
            foreach ($action_lists as $act_key => $act_row) {
              $actt_name=explode("/",$act_row['node_name']);
              if ($actt_name[2]=='menu_next_add') { //添加下级栏目
                if ($row['is_lower']!=1) {
                  continue;
                }
              }

              if ($actt_name[2]=='manage_content') { //添加下级栏目
                if ($row['is_manage']!=1) {
                  continue;
                }
              }

              echo "<a href='".U($act_row['node_name'],array('id'=>$row['id']))."' onclick='".$act_row['pre_func']."();' class='abtn'>";
              echo "<i class='".$act_row['img']."'></i>";
              echo $act_row['title'];
              echo "</a>&nbsp;";
            }
            echo "</td>";
        echo "</tr>";
        if ($row['_child']) {
          my_set_tree($row['_child'],$title_lists,$action_lists,$model,false);
        }
      }
    }

    $tree_list=menu_tree($list_data,$pk="id",$pid="parent_id",$child="_child",$root=0);
    set_tree_lev($tree_list,true);
    my_set_tree($tree_list,$title_lists,$action_lists,$THIS_MODEL['model_name'])
    ?>
    </foreach>
  </tbody>
  </table>
</block>
